import {getActiveInfo} from '@/formgen/api/index'
const activity = {
  state: {
    activity: {},
    h5Config: {},
    drawingH5: {
      draw: []
    }
  },

  mutations: {
    SET_ACTIVITY: (state, row) => {
      state.activity = row
    },
    SET_H5CONFIG: (state, obj) => {
      state.h5Config = obj
    },
    SET_drawingH5: (state, obj) => {
      state.drawingH5 = obj
    }
  },

  actions: {
    // 活动
    setActivity({ commit }, id) {
      return new Promise((resolve, reject) => {
        if(!id) {
          commit('SET_ACTIVITY', {})
          return resolve(true)
        } else{
          getActiveInfo(id).then(res => {
            commit('SET_ACTIVITY', res.data || {})
            resolve(res.data)
          })
        }
        
      })
    },
    // 活动 h5 配置
    setH5Config({ commit }, row) {
      commit('SET_H5CONFIG', row || {})
    },
    // 活动 h5 配置
    setdrawingH5({ commit }, params) {
      commit('SET_drawingH5', params || {})
    },
  },
  getters: {
    vuex_activity:(state) => state.activity,
    vuex_h5Config:(state) => state.h5Config,
    vuex_drawingH5:(state) => state.drawingH5
  }
}

export default activity
